@echo off
chcp 65001 >nul
echo ==========================================
echo 启动微服务 - 负载均衡和认证演示
echo ==========================================
echo.

echo 🚀 正在启动服务，请耐心等待...
echo.

echo [1/4] 启动Eureka Server (18000)
echo -----------------------------------------
cd Eureka_Server_18000
start "Eureka Server 18000" cmd /c "mvn spring-boot:run"
cd ..
echo ✅ Eureka Server 启动中...
timeout /t 10 /nobreak >nul

echo [2/4] 启动Provider Services (11000, 11001)
echo -----------------------------------------
cd Service_Provider_11000
start "Provider 11000" cmd /c "mvn spring-boot:run"
cd ..

cd Service_Provider_11001  
start "Provider 11001" cmd /c "mvn spring-boot:run"
cd ..
echo ✅ Provider Services 启动中...
timeout /t 15 /nobreak >nul

echo [3/4] 启动Consumer Service (16000)
echo -----------------------------------------
cd Service_Consumer_16000
start "Consumer 16000" cmd /c "mvn spring-boot:run"
cd ..
echo ✅ Consumer Service 启动中...
timeout /t 10 /nobreak >nul

echo [4/4] 启动Gateway Server (9000)
echo -----------------------------------------
cd Gateway_Server_9000
start "Gateway 9000" cmd /c "mvn spring-boot:run"
cd ..
echo ✅ Gateway Server 启动中...
timeout /t 15 /nobreak >nul

echo ==========================================
echo 所有服务启动完成！
echo ==========================================
echo.
echo 📋 服务列表：
echo - Eureka Server:    http://localhost:18000
echo - Provider 1:       http://localhost:11000
echo - Provider 2:       http://localhost:11001  
echo - Consumer:         http://localhost:16000
echo - Gateway:          http://localhost:9000
echo.
echo 🔍 测试链接：
echo - Gateway状态:      http://localhost:9000/gateway/status
echo - 服务发现:         http://localhost:9000/gateway/services
echo - 负载均衡测试:     http://localhost:9000/provider/user/instance-info
echo.
echo ⚠️  请注意：
echo 1. 服务启动需要时间，请等待所有服务完全启动
echo 2. 可以通过浏览器访问上述链接验证服务状态
echo 3. 认证测试需要添加Authorization头: "Bearer user123token"
echo.
echo 📝 运行测试脚本：
echo 负载均衡和认证测试脚本.bat
echo.
pause 